package com.chezhujie.www.service;

import com.chezhujie.www.domain.Czjrouleoff;
import com.chezhujie.www.persistence.CzjrouleoffMapper;
import com.xy.core.page.Pagination;
import com.xy.core.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("CzjrouleoffService")
public class CzjrouleoffService {
	@Autowired
	private CzjrouleoffMapper czjrouleoffMapper;

	/**
	 * 查询某个czj_rouleoff  线下轮盘
	 * @param param
	 * @return
	 */
	public Czjrouleoff getCzjrouleoff(Map<String,Object> param) {
		return czjrouleoffMapper.getCzjrouleoff(param);
	}
	
	/**
	 * 查询某个czj_rouleoff  线下轮盘
	 * @param param
	 * @return
	 */
	public List<String> getCzjrouleoffALL() {
		return czjrouleoffMapper.getCzjrouleoffALL();
	}	
   
	/**
	 * 查询某个czj_rouleoff  线下轮盘queryImgOrder
	 * @param param
	 * @return
	 */
	public Czjrouleoff queryImgOrder(Map<String,Object> param) {
		return czjrouleoffMapper.queryImgOrder(param);
	}	
	
	/**
	 * 查询czj_rouleoff  线下轮盘列表
	 * @return
	 */
	public Map<String,Object> getCzjrouleoffList(Map<String,Object> param) {
		Map<String,Object> returnMap = new HashMap<String,Object>();
		returnMap.put("totalCounts", czjrouleoffMapper.getTotalRows(param));
		returnMap.put("list", czjrouleoffMapper.getCzjrouleoffList(param));
		return returnMap;
	}
   
	
	/**
	 * 查询czj_rouleoff  线下轮盘列表
	 * @return
	 */
	public  List<Czjrouleoff> getCzjrouleoffListALL(Map<String,Object> param) {
		List<Czjrouleoff> list=	czjrouleoffMapper.getCzjrouleoffListALL(param);
		return list;
		
	}	
	
	
	
	/**
	 * 查询czj_rouleoff  线下轮盘列表
	 * @return
	 */
	public Pagination getCzjrouleoffList(Map<String,Object> param, int pageSize, Integer pageNo, String order, String sort) {
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		p.setOrder(order);
		p.setSort(sort);
		param.putAll(p.toMap());
		int count=czjrouleoffMapper.getTotalRows(param);
		List<Czjrouleoff> list=	czjrouleoffMapper.getCzjrouleoffList(param);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
		
	}
      
	/**
	 * 新增czj_rouleoff  线下轮盘
	 * @param czjrouleoff
	 * @param param
	 */
	@Transactional
	public void insertCzjrouleoff(Czjrouleoff czjrouleoff) {	
		czjrouleoff.setRouleoffId(UUIDUtils.getUUID());
		czjrouleoffMapper.insertCzjrouleoff(czjrouleoff);
	}
   
	/**
	 * 编辑czj_rouleoff  线下轮盘
	 * @param czjrouleoff
	 * @param param
	 */
	@Transactional
	public void updateCzjrouleoff(Czjrouleoff czjrouleoff) {
		czjrouleoffMapper.updateCzjrouleoff(czjrouleoff);
	}
   
	/**
	 * 删除czj_rouleoff  线下轮盘
	 * @param param
	 */    
	@Transactional
	public void deleteCzjrouleoff(List<String> rouleoffIdList) {
		for(String rouleoffId: rouleoffIdList){
	  		Map<String,Object> param = new HashMap<String,Object>();
	  		param.put("rouleoffId", rouleoffId);
	 	   czjrouleoffMapper.deleteCzjrouleoff(param);	  		
		}
	}


}